// 对外暴露插件对象
// 自定义插件语法

import SvgIcon from './SvgIcon/index.vue'
import Pagination from './Pagination/index.vue'
import CategorySelect from './CategorySelect/index.vue'
// 引入element-plus 提供全部的图标组件
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// console.log(ElementPlusIconsVue);

// import type { App, Component } from 'vue';
// const components: { [name: string]: Component } = { SvgIcon };
const allGlobalComponent = { SvgIcon, Pagination, CategorySelect }
// console.log(allGlobalComponent)

export default {
  // 务必叫做install 方法
  install(app: any) {
    // 注册项目全部的全局组件
    Object.keys(allGlobalComponent).forEach((key) => {
      //   console.log(key)
      // 注册为全局组件
      app.component(key, allGlobalComponent[key])
    })
    // 讲element-plus 提供的图标注册为全局组件
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      app.component(key, component)
    }
  },
}
